
package net.display;

import net.bo.KPlan;
import net.ko.displays.KObjectDisplay;
import net.ko.kobject.KObject;
import javax.servlet.http.HttpServletRequest;

import net.bo.KUtilisateur;
import net.ko.framework.KoSession;
import net.ko.http.views.KobjectHttpAbstractView;

public class DisplayPlan extends KObjectDisplay {

	@Override
	public String showInList(KObject ko, String memberName,HttpServletRequest request) {
		String res=super.showInList(ko, memberName,request);
		KPlan plan=(KPlan) ko;
		
		if("cocher".equals(memberName)){
			res="<input  id='plan-"+plan.getId()+"' type='checkbox' value="+plan.getId()+" />";
			
			}
		
		return res;
	}

	@Override
	public void afterLoading(KObject ko, KobjectHttpAbstractView view,
			HttpServletRequest request) {
		// TODO Auto-generated method stub "+KRequest.GETPOST("login", request)+"
		KUtilisateur user=KoSession.kloadOne(KUtilisateur.class,"login='jcheron'");
		KPlan plan=(KPlan)ko;
		plan.setIdUtilisateur(Integer.valueOf(user.getId()+""));
		plan.setActive(true);
		request.getSession().setAttribute("plan", plan);
		super.afterLoading(plan, view, request);
	}

}

